﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for CourseView.xaml
    /// </summary>
    public partial class CourseView : Page
    {
        public CourseView()
        {
            InitializeComponent();
        }

        private void addCrseBtn_Click_1(object sender, RoutedEventArgs e)
        {
            CourseAdd crseAddWindow = new CourseAdd();
            crseAddWindow.Content = null;
            mainContent.Children.Add(crseAddWindow.mainContent);
        }

        private void updateCrseBtn_Click_1(object sender, RoutedEventArgs e)
        {
            CourseUpdate crseUpdateWindow = new CourseUpdate();
            crseUpdateWindow.Content = null;
            mainContent.Children.Add(crseUpdateWindow.mainContent);
        }

        private void deleteCrseBtn_Click_1(object sender, RoutedEventArgs e)
        {
            CourseDelete crseDeleteWindow = new CourseDelete();
            crseDeleteWindow.Content = null;
            mainContent.Children.Add(crseDeleteWindow.mainContent);
        }

        private void searchCrseBtn_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void crseView_Update_Click_1(object sender, RoutedEventArgs e)
        {
            CourseUpdate crseUpdateWindow = new CourseUpdate();
            crseUpdateWindow.Content = null;
            mainContent.Children.Add(crseUpdateWindow.mainContent);

            DataRowView drv = (DataRowView)displayCrseDetailsLstvw.SelectedItem;
            string x = drv.Row["courseID"].ToString();
            crseUpdateWindow.crseIDCmbx.Text = x;
        }

        private void crseView_Delete_Click_1(object sender, RoutedEventArgs e)
        {
            CourseDelete crseDeleteWindow = new CourseDelete();
            crseDeleteWindow.Content = null;
            mainContent.Children.Add(crseDeleteWindow.mainContent);

            DataRowView drv = (DataRowView)displayCrseDetailsLstvw.SelectedItem;
            string x = drv.Row["courseID"].ToString();
            crseDeleteWindow.crseIDCmbx.Text = x;
        }

        private void crseView_Cancel_Click_1(object sender, RoutedEventArgs e)
        {
            displayCrseDetailsLstvw.SelectedItem = "";
        }

        private void mainContent_Loaded_1(object sender, RoutedEventArgs e)
        {
            Database.populateCrseListview(this);
        }
    }
}
